<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="/WEB-INF/tld/FCKeditor.tld" prefix="FCK" %><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!--取出window对象-->
<c:set var="window" value="${sessionScope[requestScope.jwas_single_window_id]}"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>${window.desc }</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link rel="StyleSheet" href="cep/css/cep.css" type="text/css"/>
  </head>
  <script type="text/javascript" src="FCKeditor/fckeditor.js"></script>
  <script type="text/javascript" src="cep/js/validation/validation.js"></script>
  <script type="text/javascript" src="cep/js/validation/form_auto_validation.js"></script>
  <script type="text/javascript" src="cep/js/sort.js"></script>
  <body>
    <b>${window.desc }</b><span style="padding-left:50px;color: #700700" id="easy_mana_err_span">${message }<font color="red"> ${err_msg}</font></span>
    <c:if test="${empty window}" var ="noWindow">
    <!--如果没有，取得这个窗体的属性 -->
	   not window
    </c:if><c:if test = "${!noWindow}"><c:set var = "rowNum" value = "${window.dispCol}"/><!-- 显示表属性，并且以表单形式呈现 -->
    <form name="form_jump_page" method="${window.method}" action="${window.action}">
    	<INPUT type="hidden" name="action" value="topage" />
    	<INPUT type="hidden" name="toPage" value="" />
    </form>
    <FORM name="${window.formName}" method= "${window.method}" action="${window.action}">
    	<INPUT type="hidden" name="jwas_single_window_id" value="${requestScope.jwas_single_window_id}" />
	    <TABLE width="100%">
	    <c:set var="posi" value="${-1}"></c:set>
    	<c:forEach var="fele"  items="${window.fields}" varStatus="status">
    	<c:set var="fht" value="${fele.htmlType}">
    	</c:set><c:set var="fn" value="${fele.fieldName}"></c:set>
    		<c:if test="${fht != 'hidden'}" var = "notHidden" scope="page"><c:set var="posi" value="${posi + 1}"></c:set></c:if>
    		<c:if test="${notHidden && posi % rowNum == 0}"><tr></c:if>
    		<c:if test="${!notHidden}"><input type = "${fht}" name="${fn}" value="${fele.value}" size="${fele.size}" ${fele.readonly ? 'readonly=readonly' : '' }/></c:if>
    		<c:if test="${notHidden && fht != 'select' && fht != 'textarea' && fht != 'fckeditor'}">
	    		<td>${fele.dispText}</td><TD><input type = '${fht}' name="${fn}" size="${fele.size}" <c:if test="${fele.readonly }">value="${fele.value}" readonly='readonly'</c:if> limit="${fele.limits}" msg="${fele.comment}"></TD>
    		</c:if>
	    		<c:if test = "${fht == 'select'}">
	    			<td>${fele.dispText}</td>
	    			<td><SELECT name="${fn}" value="${fele.value}" <c:if test="${fele.onchange != null}">onchange = "${fele.onchange}"</c:if>  limit="${fele.limits}" msg="${fele.comment}" <c:if test="${fele.readonly}"> readonly="readonly"</c:if>>
	    				<option value="">未选择</option>
	    				<c:forEach var="option" items="${fele.dispList}"><option value="${option.key}">${option.value}</option></c:forEach>
	    				</SELECT></td>
	    		</c:if>
	    		<c:if test = "${fht == 'textarea'}">
	    			<td>${fele.dispText}</td><td><textarea name="${fn}" rows="${fele.rows}" cols="${fele.cols}"  limit="${fele.limits}" msg="${fele.comment}"></textarea></td>
	    		</c:if>
	    		<c:if test = "${fht == 'fckeditor'}">
	    			<c:if test="${posi%rowNum == 0}"><td></td></tr><tr>
	    			</c:if>
	    			<c:if test="${posi%rowNum == 1}"></tr>
		    			<tr>
	    			</c:if>
	    			<td>${fele.dispText}</td>
	    			<td colspan="3">
	    			<textarea id="${fn}" name="${fn}" cols="${fele.cols}" rows="${fele.rows}" editor="fckeditor2.3"></textarea>
						<script type="text/javascript">
						 var oFCKeditor = new FCKeditor('${fn}') ;
						 oFCKeditor.BasePath = 'FCKeditor/';
						 oFCKeditor.ToolbarSet = "Basic" ;
						 oFCKeditor.Height = ${fele.rows};
						 oFCKeditor.Width = ${fele.cols};
						 //oFCKeditor.ToolbarSet = "Gk" ; 
						 oFCKeditor.ReplaceTextarea();
						</script>
	    			</td>
	    			<c:if test="${posi % rowNum == 0}">
	    				</tr><tr>
	    			</c:if>
	    		</c:if>
	    	<c:if test="${notHidden && posi % rowNum == 1}">
    			</tr>
    		</c:if>
    	</c:forEach>
	<!-- 操作按纽 -->
	<tr>
    <td colspan="4">
    	<c:if test="${window.methods != null}">
    		<c:forEach items="${window.methods}" var="method">
    			<c:if test="${method == 'query'}">
    				<input type="button" onclick="operateForm('query');" value="查询" id="but_quer"/>
    			</c:if><c:if test="${method == 'add'}">
    				<input type="button" onclick="addRecord();" value="新增" id="but_inse"/>
    			</c:if><c:if test="${method == 'update'}">
    				<input type="button" onclick="operateForm('update');" value="保存" id="but_upda"/>
    			</c:if><c:if test="${method == 'delete'}">
    				<input type="button" onclick="operateForm('delete');" value="删除" id="but_dele"/>
    			</c:if>
    		</c:forEach>
    	</c:if>
    </td>
  </tr>
	    </TABLE>
    </FORM>
    </c:if>
    <hr>
    <!-- 显示结果集 -->
    <!--取出Table对象-->
    <c:set value="window_${window.id}" var="tableSessionName"></c:set>
    <c:set var="dtable" value="${requestScope[tableSessionName]}"/>
    <c:set var="noData" value="${dtable == null || dtable.rows == null}"/>
    <c:if test="${!noData}">
    <span class="page_desc">Page:${dtable.currentPage}/${dtable.pageCount} &nbsp;&nbsp;${fn:length(dtable.rows)} resords. Total record:${dtable.recordCount}</span>
    <!-- 显示表头 --><!-- 显示表体 -->
    <div class="single_grid_window">
    <c:set var="index_start" value="${(dtable.currentPage - 1) * dtable.pageSize}"></c:set>
    <table cellspacing="1" cellpadding="3" style="background-color: #000000;" id="${dtable.id}">
   		<!-- 输出表头 -->
   		<tr style="font-weight: bold;cursor:pointer">
   			<td onclick="sort_this_table(this)">序号</td>
   			<c:forEach items="${dtable.th}" var="th">
   				<td onclick="sort_this_table(this)" id="${th.id }" <c:if test="${th.width != null}">width="${th.width}"</c:if>>${th.value}</td>
   			</c:forEach>
   		</tr>
   		<!-- 输出表数据 -->
   		<c:forEach items="${dtable.rows}" var="row" varStatus="i"><tr onmousemove="mOvr(this)" onmouseout="mOut(this)" onclick="copy(this,false)">
   				<td>${i.index + 1}</td>
   				<c:forEach items="${row}" var="td" varStatus="j">
   					<c:set var="isPop" value="${td.dispMode == 'pop'}"></c:set><c:set var="isHiddendiv" value="${td.dispMode == 'hiddendiv'}"></c:set>
   					<td <c:if test="${isPop}">onmouseover="dispTd('div_${i.index}_${j.index}')" onmouseout="hideTd('div_${i.index}_${j.index}')"</c:if><c:if test="${td.onclick != null}"> onclick=${td.onclick }</c:if> <c:if test="${td.title != null}"> title="${td.title}"</c:if>>
   					<c:if test="${td.linkUrl != null}" var="hasLink"><a href="${td.linkUrl}"></c:if>
   					<c:if test="${isPop || isHiddendiv}" var="hide"><div id="div_${i.index}_${j.index}" style="display:none">${td.value}</div></c:if>
   					${(isPop || isHiddendiv) ? td.goat : td.value}
   					<c:if test="${hasLink}"></a></c:if>
   					</td>
   				</c:forEach>
   			</tr>
   		</c:forEach>
   	</table>
    <DIV class="page_index">
      <c:set value="${dtable.currentPage}" var="midder"/>
      <c:if test="${midder - 6 < 0}" var="x6">
      	<c:set value="${1}" var="start"></c:set>
      	<c:if test="${dtable.pageCount > 10}" var="last">
      		<c:set value="${10}" var="end"></c:set>
      	</c:if>
      	<c:if test="${!last}">
      	<c:set value="${dtable.pageCount}" var="end"></c:set>
      	</c:if>
      </c:if>
     <c:if test="${!x6}">
      	<c:if test="${midder + 5 >= dtable.pageCount}">
      		<c:set value="${dtable.pageCount}" var="end"></c:set>
      	</c:if>
      	<c:if test="${midder + 5 < dtable.pageCount}" var="last">
      		<c:set value="${midder + 5}" var="end"></c:set>
      	</c:if>
      	<c:if test="${end - 10 > 0}" var="first">
      		<c:set value="${end - 10}" var="start"></c:set>
      	</c:if>
      	<c:if test="${!first}">
      		<c:set value="${1}" var="start"></c:set>
      	</c:if>
      </c:if>
      GO PAGE:<c:if test="${first}"><A href="javaScript:goPage(${1});">First</A></c:if>
      <c:forEach begin="${start}" end="${end}" var="i">
      	<c:if test="${i == dtable.currentPage}" var="test"><A href="javaScript:goPage(${i});"><span class="page_index_current">&nbsp;${i}</span></A></c:if>
      	<c:if test="${!test}"><A href="javaScript:goPage(${i});">&nbsp;${i}</A></c:if>
      </c:forEach>
      <c:if test="${last}"><A href="javaScript:goPage(${dtable.pageCount});">&nbsp;Last</A></c:if>
      </DIV>
    </div>
    </c:if>
    <div id="display" class="display"></div>
  </body>
<script type="text/javascript" src="cep/js/window.js"></script>
<script type="text/javascript" src="cep/js/window_copy.js"></script>
<script language="javascript">
	setTableId("t_${table}");
	setFormName("${window.formName}");
</script>
</html>